home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / NetPokerForMacOSX_Server / HoldEmHigh / Player.m < prev    next >
Encoding:
Text File  |  1999-06-26  |  1.7 KB  |  115 lines

  1. #import "poker.h"
  2.  
  3. @implementation Player
  4.  
  5.  
  6. - (id)initWithName:(NSString *)name pokerTable:(PokerTable *)pokerTable
  7. {
  8.     self = [super init];
  9.     table = pokerTable;
  10.     playerName = [name copyWithZone:[self zone]];
  11.     [self setIsMe:[[[NSApp delegate] userName] isEqualToString:playerName]];
  12.     [self getNewHand];
  13.     return self;
  14. }
  15.  
  16. - (void)dealloc {
  17.     [playerName release];
  18.     [super dealloc];
  19. }
  20.  
  21. - (NSString *)specialStatus {
  22.     if (hasFolded) {
  23.         if (onVacation) return @"\nFolded\nVacation";
  24.     return @"\nFolded";
  25.     } else if (onVacation) return @"\nVacation";
  26.     else if ([table isButtonPlayer:self]){
  27.         if (onVacation) return @"\nB\nVacation";
  28.         if (hasFolded) return @"\nB\nFolded";
  29.         return @"\nB";
  30.     }
  31.     else return @"";
  32. }
  33.  
  34. - (BOOL)isMe {
  35.    return isMe;
  36. }
  37.  
  38. - (void)setIsMe:(BOOL)isOwner {
  39.    isMe = isOwner;
  40. }
  41.  
  42.  
  43. - (NSString *)buttonTitle // a formatted string with player name and amount and status
  44. {
  45.     return [NSString stringWithFormat:@"%@\n$ %d%@",playerName,stack,[self specialStatus]];
  46. }
  47.  
  48. - (NSString *)playerName {
  49.    return playerName;
  50. }
  51.  
  52. - (void)fold
  53. {
  54.     hasFolded = YES;
  55. }
  56.  
  57. - (BOOL)hasFolded {
  58.     return hasFolded;
  59. }
  60.  
  61. - (BOOL)onVacation {
  62.     return onVacation;
  63. }
  64.  
  65. - (void)setOnVacation:(BOOL)isOwner
  66. {
  67.     onVacation = isOwner;
  68. }
  69.  
  70. - (int)column
  71. {
  72.     return column;
  73. }
  74.  
  75. - (void)setColumn:(int)aCol
  76. {
  77.     column = aCol;
  78. }
  79.  
  80. - (int)row
  81. {
  82.     return row;
  83. }
  84.  
  85.  
  86. - (void)setRow:(int)aRow
  87. {
  88.     row = aRow;
  89. }
  90.  
  91. - (HoldEmHighHoleHand *)holeHand
  92. {
  93.     return holeHand;
  94. }
  95.  
  96. // call at new game:
  97. - (void)getNewHand;
  98. {
  99.    [holeHand release];
  100.    hasFolded = NO;
  101.     holeHand = [[HoldEmHighHoleHand allocWithZone:[self zone]] init];
  102. }
  103.  
  104. - (void)setStackAmount:(int)amount
  105. {
  106.     stack = amount;
  107. }
  108.  
  109. - (int)stackAmount
  110. {
  111.     return stack;
  112. }
  113.  
  114. @end
  115.